package ar.com.psicosoft.model.psicosoft;

import java.io.Serializable;

import javax.persistence.*;

import java.sql.Timestamp;

/**
 * The persistent class for the estado_civil database table.
 * 
 */
@Entity
@Table(name = "estado_civil", schema = "psicosoft")
@NamedQueries({
		@NamedQuery(name = "EstadoCivil.buscarPorId", query = "SELECT e FROM EstadoCivil e WHERE e.idEstadoCivil = :idEstadoCivil", lockMode = LockModeType.NONE),
		@NamedQuery(name = "EstadoCivil.buscarPorNombreEstadoCivil", query = "SELECT e FROM EstadoCivil e WHERE e.nombreEstadoCivil = :nombreEstadoCivil", lockMode = LockModeType.NONE),
		@NamedQuery(name = "EstadoCivil.buscarEstadosCiviles", query = "SELECT e FROM EstadoCivil e ORDER BY e.nombreEstadoCivil", lockMode = LockModeType.NONE),
		@NamedQuery(name = "EstadoCivil.eliminarEstadoCivilPorId", query = "DELETE FROM EstadoCivil e WHERE e.idEstadoCivil = :idEstadoCivil", lockMode = LockModeType.NONE) })
public class EstadoCivil implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name = "sec_estado_civil", sequenceName = "psicosoft.sec_estado_civil", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sec_estado_civil")
	@Column(name = "\"idEstadoCivil\"", unique = true, nullable = false, insertable = false, updatable = false)
	private Integer idEstadoCivil;

	@Column(nullable = true)
	private Timestamp baja;

	@Column(name = "\"nombreEstadoCivil\"", nullable = false, length = 30, unique = true)
	private String nombreEstadoCivil = null;

	// bi-directional many-to-one association to Persona
	// @OneToMany(mappedBy = "estadoCivil", targetEntity = Persona.class)
	// private List<Persona> personas = null;

	public EstadoCivil() {
	}

	/**
	 * @param nombreEstadoCivil
	 */
	public EstadoCivil(String nombreEstadoCivil) {
		super();
		this.nombreEstadoCivil = nombreEstadoCivil;
	}

	public Integer getIdEstadoCivil() {
		return this.idEstadoCivil;
	}

	public void setIdEstadoCivil(Integer idEstadoCivil) {
		this.idEstadoCivil = idEstadoCivil;
	}

	public Timestamp getBaja() {
		return this.baja;
	}

	public void setBaja(Timestamp baja) {
		this.baja = baja;
	}

	public String getNombreEstadoCivil() {
		return this.nombreEstadoCivil;
	}

	public void setNombreEstadoCivil(String nombreEstadoCivil) {
		this.nombreEstadoCivil = nombreEstadoCivil;
	}

	/*
	 * public List<Persona> getPersonas() { return this.personas; }
	 * 
	 * public void setPersonas(List<Persona> personas) { this.personas =
	 * personas; }
	 * 
	 * public Persona addPersona(Persona persona) { getPersonas().add(persona);
	 * persona.setEstadoCivil(this);
	 * 
	 * return persona; }
	 * 
	 * public Persona removePersona(Persona persona) {
	 * getPersonas().remove(persona); persona.setEstadoCivil(null);
	 * 
	 * return persona; }
	 */
	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((baja == null) ? 0 : baja.hashCode());
		result = prime
				* result
				+ ((nombreEstadoCivil == null) ? 0 : nombreEstadoCivil
						.hashCode());
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EstadoCivil other = (EstadoCivil) obj;
		if (baja == null) {
			if (other.baja != null)
				return false;
		} else if (!baja.equals(other.baja))
			return false;
		if (nombreEstadoCivil == null) {
			if (other.nombreEstadoCivil != null)
				return false;
		} else if (!nombreEstadoCivil.equals(other.nombreEstadoCivil))
			return false;
		return true;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "EstadoCivil [idEstadoCivil=" + idEstadoCivil
				+ ", nombreEstadoCivil=" + nombreEstadoCivil + "]";
	}

}